package bos.web.action;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import bos.domain.Staff;
import bos.service.IStaffService;
import bos.web.action.base.BaseAction;

@Controller
@Scope("prototype")
public class StaffAction extends BaseAction<Staff> {
	@Autowired
	private IStaffService staffService;
	

	public String add(){
		staffService.save(model);
		return "list";
	}
	
	public String pageQuery() throws Exception{
		staffService.pageQuery(pageBean);
		
		this.writePageBean2Json(pageBean, new String[]{"currentPage","detachedCriteria","pageSize","decidedzones"});
	return NONE;	
	}
	private String ids;

	public void setIds(String ids) {
		this.ids = ids;
	}
	@RequiresPermissions(value="staff")
	public String delete(){
		staffService.deleteBatch(ids);
		return "list";
	}
	public String edit(){
		Staff staff=staffService.findById(model.getId());
		staff.setName(model.getName());
		staff.setTelephone(model.getTelephone());
		staff.setStation(model.getStation());
		staff.setHaspda(model.getHaspda());
		staff.setStandard(model.getStandard());
		staffService.update(staff);
		return "list";
	}
	public String listajax() throws Exception{
		List<Staff> list=staffService.findListNotDelete();
		String[] excludes=new String[]{"decidedzones"};
		this.writeList2Json(list, excludes);
		return NONE;
	}
}
